#!/usr/bin/python
# -*- coding: UTF-8 -*-

"""
@author: jiu
@contact: 643562684@qq.com
@time: 2022/3/10 15:17
"""
from selenium.webdriver import Firefox, FirefoxOptions

from Conf.setting import *
from browser.base_browser import BASE


class FIREFOX(BASE):
    _browser_mark = True
    _option_mark = True

    def __init__(self, *args, **kwargs):
        super(FIREFOX, self).__init__(
            browser_type=Firefox,
            browser_option=FirefoxOptions,
            driver_path=BASE.CHROME_PATH
        )

    @property
    def browser(self):
        browser = self._browser(self._driver_path, self.option)
        if self._browser_mark:
            browser.set_page_load_timeout(CHROME_LOAD_PAGE_TOME)
            browser.set_script_timeout(CHROME_SCRIPT_TIME)
            # browser.implicitly_wait(CHROME_IMP)
            # browser.maximize_window()

        return browser

    @property
    def option(self):
        option = self._option()
        if self._option_mark:
            option.ensure_clean_session = True
            option.add_experimental_option('useAutomationExtension', False)
            option.add_experimental_option('excludeSwitches', ['enable-automation'])
            option.add_argument("start-maximized")  # 初始化就最大化

        return option
